'use strict';

module.exports = app => {
  const { router, controller, middleware } = app;

  // 上传文件
  router.post('/api/upload/file', controller.common.upload.cos);
  router.get('/api/file/list', controller.common.file.list);
  router.resources('file', '/api/file', controller.common.file);
  
  // 配置
  router.get('/api/config/list', controller.business.config.list);
  router.get('/api/config/key/:key', controller.business.config.getByKey);
  router.resources('config', '/api/config', controller.business.config);

  // ----------------------业务模块----------------------------//
  // 创业补贴
  router.resources('startupSubsidy', '/api/startup-subsidy', controller.business.startupSubsidy);
  
  // 购房补贴
  router.resources('housingPurchaseSubsidy', '/api/housing-purchase-subsidy', controller.business.housingPurchaseSubsidy);
  
  // 就业补贴
  router.resources('employmentSubsidy', '/api/employment-subsidy', controller.business.employmentSubsidy);
  
  // 落户补贴
  router.resources('settlementSubsidy', '/api/settlement-subsidy', controller.business.settlementSubsidy);
  
  // 保障房
  router.resources('affordableHousing', '/api/affordable-housing', controller.business.affordableHousing);
  
  // 青年公寓
  router.resources('youthHostel', '/api/youth-hostel', controller.business.youthHostel);
  
  // 就业补贴
  router.resources('jobSubsidy', '/api/job-subsidy', controller.business.jobSubsidy);
  
  // 青创贷
  router.resources('youthStartupLoan', '/api/youth-startup-loan', controller.business.youthStartupLoan);
  
  // 技能提升补贴
  router.resources('skillSubsidy', '/api/skill-subsidy', controller.business.skillSubsidy);
  
  // 户口迁入审批
  router.resources('householdMove', '/api/household-move', controller.business.householdMove);

  // ----------------------租户----------------------------//
  // 租户登录/system/auth/login
  router.post('/api/system/auth/login', controller.system.systemUser.login)
  // 获取租户信息和权限
  router.get('/api/system/auth/get-permission-info', middleware.auth(), controller.system.systemUser.getUserInfo)
  router.resources('/api/system/user', middleware.auth(), controller.system.systemUser);
  // 租户菜单
  router.get('/api/system/menu/tree', middleware.auth(), controller.system.systemMenu.tree);
  router.resources('/api/system/menu', middleware.auth(), controller.system.systemMenu);
  // 角色
  router.get('/api/system/role/list', middleware.auth(), controller.system.systemRole.list);
  router.resources('/api/system/role', middleware.auth(), controller.system.systemRole);
  // 权限
  router.get('/api/system/permission/list-user-roles', middleware.auth(), controller.system.systemPermission.getUserRoles);
  router.post('/api/system/permission/assign-user-role', middleware.auth(), controller.system.systemPermission.updateUserRoles);
  router.get('/api/system/permission/list-role-menus', middleware.auth(), controller.system.systemPermission.listRoleMenus);
  router.post('/api/system/permission/assign-role-menu', middleware.auth(), controller.system.systemPermission.updateRoleMenus);
};
